class Solution:
    def arrangeCoins(self, n: int) -> int:
        i, j = 1, 2147483647
        mid, temp = 0, 0
        while i < j:
            mid = i + ((j - i) >> 1)
            temp = ((1 + mid) * mid) >> 1
            if temp >= n:
                j = mid
            else:
                i = mid + 1
        return mid if temp == n else mid - 1
